/**
* @Author: zmx
* @Date: 2023/9/26
* @Description:
*/
<template>
  <el-dialog :title="'实时监控'" :visible.sync="show" append-to-body width="1400px" :before-close="cancel">
    <div class="videoContent">
      <div class="left">
        <div>
          <span>任务名称：</span>
          <span>{{ info.taskName }}</span>
        </div>
        <div>
          <span>方案名称：</span>
          <span>{{ info.patrolPlanName }}</span>
        </div>
        <div>
          <span>巡检类型：</span>
          <span>{{ info.patrolPlanType }}</span>
        </div>
        <div>
          <span>巡检作业项：</span>
          <span></span>
        </div>
        <div>
          <el-table :data="tableData" style="width: 300px" :show-header="false">
            <el-table-column type="expand" width="50">
              <template v-slot="scope">
                <el-table :data="scope.row.subVOList" style="width: 100%" :show-header="false">
                  <el-table-column width="50px">
                  </el-table-column>
                  <el-table-column prop="assignSubName" label="场站名称"></el-table-column>
                  <el-table-column prop="assignContentDesc" label="描述"></el-table-column>
                </el-table>
              </template>
            </el-table-column>
            <el-table-column prop="assignName" label="场站名称" width="180"></el-table-column>
          </el-table>
        </div>
        <div class="centerStation">
          <el-table :data="this.info.warnVOList"  height="200" :cell-style="{'text-align':'center'}" :header-cell-style="{background:'#D6D6D6',color:'#404040',textAlign:'center'}" style="width: 300px">
            <el-table-column prop="stakeName" label="桩名称"></el-table-column>
            <el-table-column prop="warnNum" label="告警数量">
              <template v-slot="scope">
                <span :style="{color:Number(scope.row.warnNum)>0?'red':''}">{{ scope.row.warnNum }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="riskClass" label="危险等级">
              <template v-slot="scope">
                <span :style="{color: warnList[Number(scope.row.riskClass)-1].color}">{{ warnList[Number(scope.row.riskClass)-1].name }}</span>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div class="center">
        <el-table :data="tableDataList" :header-cell-style="{background:'#D6D6D6',color:'#404040'}" style="width: 300px">
          <el-table-column label="序号" width="50">
            <template v-slot="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
          <el-table-column prop="name" label="名称" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="操作" width="80px">
            <template v-slot="scope">
              <el-button class="common-btn" >查看</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="right">
        <div style="margin-top: 15px;margin-bottom: 10px">
         {{row.stationName}}
        </div>
        <div style="width: 100%;">
          <Artplayer :cream="true" @get-instance="getInstance" @screenshot="screenshot" :option="option" :style="style"/>
          <div class="bottomImg" v-if="brightList&&brightList.length>0">
            <div class="brightImg">
              已截图
            </div>
            <div class="brightBox" v-for="(item,index) in brightList" :key="item">
              <div class="imgBox">
                <img :src="item" alt="">
                <div class="deleteImg" @click="deleteImg(item,index)">x</div>
              </div>
              <div class="addBright" @click="addBright(item)">添加说明</div>
            </div>
          </div>
          <!--          已巡检作业项-->
          <div class="center">
          <el-table :data="inspectedList"  height="200" :cell-style="{'text-align':'center'}" :header-cell-style="{background:'#D6D6D6',color:'#404040',textAlign:'center'}">
            <el-table-column prop="assignSubName" label="作业项"></el-table-column>
            <el-table-column prop="checkStatus" label="状态">
              <template v-slot="scope">
                <span>{{scope.row.checkStatus==0?'正常':'异常' }}</span>
              </template>
            </el-table-column>
            <el-table-column prop="warnNum" label="危险等级">
              <template v-slot="scope">
                <span>{{warnList[scope.row.checkStatus].name}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="checkDesc" label="结论">
              <template v-slot="scope">
                <el-tooltip placement="top">
                  <span slot="content">{{ scope.row.checkDesc }}</span>
                  <span class="tooltipClass">{{ scope.row.checkDesc }}</span>
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column label="操作">
              <template v-slot="scope">
                <el-button class="common-btn" @click="getDetail(scope.row)">查看截图</el-button>
                <el-image
                  ref="imageRef"
                  v-show="false"
                  style="width: 100px; height: 100px"
                  :src="scope.row.checkUrl"
                  :zoom-rate="1.2"
                  :preview-src-list="[scope.row.checkUrl]"
                  :initial-index="1"
                  fit="cover"
                />
              </template>
            </el-table-column>
          </el-table>
          </div>
        </div>
      </div>
      <brightDialog v-if="brightDialog" :brightDialog="brightDialog" @closeDialog="closeDialogBright" :urlImg="urlImg" :info="info" :row="row"></brightDialog>
    </div>
  </el-dialog>
</template>

<script>
import {patrol} from '../../api/inspection/apiUntil'
import Artplayer from "./Artplayer.vue";
import brightDialog from './brightDialog'
import video from '../../../static/img/sqldev_20230902.mp4'
import {getPlanRecord} from "../../api/inspection/pator";

export default {
  props: ['DialogVideo', 'row'],
  components: {
    Artplayer,
    brightDialog
  },
  data() {
    return {
      option: {
        url: video,
      },
      inspectedList:[],
      warnList:[
        {
          name:'暂无风险',
          color:'green'
        },
        {
          name:'低风险',
          color:'green'
        },
        {
          name:'中风险',
          color:'#FF8D1A'
        },
        {
          name:'高风险',
          color:'#FF0000'
        },
        {
          name:'重大风险',
          color:'red'
        },
      ],
      brightDialog: false,
      style: {
        width: "100%",
        height: "300px",
      },
      show: false,
      tableData: [],
      info: '',
      tableDataList: [],
      brightList: [],
      urlImg: '',
    };
  },
  mounted() {
    //显示弹窗
    this.show = this.DialogVideo
    this.getInit()
    this.getPatrolCameraList()
    this.getVideoList()
  },
  methods: {
    getDetail(){
      this.$refs.imageRef.showViewer = true
    },
    cancel() {
      this.show = false
      this.$parent.cancel()
    },
    getVideoList(){
      patrol.getPlanRecord({taskCurrentId: this.row.id}).then((res) => {
        if (res.data) {
          this.inspectedList = res.data
        }
      })
    },
    addBright(urlImg) {
      this.brightDialog = true
      this.urlImg = urlImg
    },
    getInstance(art) {
      // console.info(art, 'mmmm');
    },
    screenshot(url) {
      this.brightList.push(url)
    },
    deleteImg(el,index){
      this.brightList.splice(index,1)
    },
    getInit() {
      patrol.getPatrolInfo({id: this.row.id}).then((res) => {
        if (res.data) {
          this.tableData = res.data.assignmentVO
          this.info = res.data
        }
      })
    },
    //获取摄像头列表
    getPatrolCameraList() {
      patrol.getPatrolCameraList({stationName: this.row.stationName}).then((res) => {
        if (res) {
          // console.log(res.data )
          this.tableDataList = res.data
        }
      })
    },
    closeDialogBright() {
      this.brightDialog = false
      this.getVideoList()
    },
    handleClose() {
      this.show = false
      this.$emit('closeDialog')
    }
  }
};
</script>

<style lang="scss" scoped>
> > > .el-dialog__header {
  padding: 20px !important;
  background: #1B7B87;
}

> > > .el-dialog__title {
  color: #fff !important;
  font-size: 16px;
}

> > > .el-dialog__body {
  padding-top: 0;
}

> > > .el-table {
  margin-top: 0;
}

.videoContent {
  display: flex;

  .left {
    width: 300px;
    margin-right: 10px;

    div {
      margin-top: 15px;

      span {
        display: inline-block;

      }
    }

  }

  .center {
    margin-top: 15px;
    border-radius: 4px;
    border: 1px solid #c2c1c1;
    margin-right: 20px;
  }

  .right {
    flex: 1;
  }
}

.bottomImg {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-top: 20px;
  overflow: hidden;

  .brightImg {
    width: 30px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    color: #ccc;
    background: #7f7e7e;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    margin-right: 10px;
    padding: 15px 0;
  }

  .brightBox {
    display: flex;
    height: 80px;
    align-items: center;
    margin-right: 15px;
    margin-top: 10px;
    margin-bottom: 10px;

    .addBright {
      width: 25px;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      color: red;
      border: 1px solid red;
      text-align: center;
      font-size: 16px;
      margin-left: 10px;
      cursor: pointer;

    }

    .imgBox {
      width: 100px;
      height: 80px;
      position: relative;

      .deleteImg {
        position: absolute;
        right: 5px;
        top: 0;
        cursor: pointer;
      }

      img {
        height: 100%;
        width: 100%;
        object-fit: cover;
      }
    }
  }

}
</style>
